<template>
  <div style="padding: 16px;">
    <div
      style="font-size: 26px;font-weight: 600;color: #1D2129;margin-bottom: 16px;"
    >
      体校类别
    </div>
    <div
      style="background: #F3F3F3; width: 100%;height: 40px;line-height: 40px;display: flex;justify-content: space-between;padding: 0 12px;"
    >
      <div style="font-size: 12px;">全省体校数量/所</div>
      <div style="font-size: 18px;color: #0F0F0F;">3628</div>
    </div>
    <div style="width:100%;height:300px;" id="aa"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "SchoolType",
  data() {
    return {
      chartInstance: null
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    datalist() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("aa"));
      // 指定图表的配置项和数据
      var option;

      option = {
        title: {
          left: "center"
        },
        tooltip: {
          trigger: "item"
        },
        legend: {
          orient: "vertical",
          left: "left"
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: [
              { value: 1048, name: "省级" },
              { value: 735, name: "地市级" },
              { value: 580, name: "县级" }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)"
              }
            }
          }
        ]
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);

      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          myChart.resize();
        }
      });

      ro.observe(cc);
    }
  }
};
</script>

<style scoped>
h2 {
  margin-bottom: 20px;
}
</style>
